#!/bin/python

from compiler import *
from tester import *


class compileandtest():

    def __init__(self,sourcefile,proid):
        self.sourcefile = sourcefile
        self.proid = proid
        self.compiler = Compiler()
        self.status=[-1]
    def do(self):
        csucc, cmsg = self.compiler.compile_source(self.sourcefile)
        if csucc:
            self.tester = Tester()
            self.status[0] = 0 # compile passed.
            retcode = self.tester.test_(self.sourcefile[:-2],self.proid)  #sourcefile ends with '.c'
            self.status.append(retcode)
        else:
            self.status[0]= -1 # compile failed.
            self.status.append(cmsg)
    def report(self):
        return self.status
if __name__ == "__main__":
    c = compileandtest("simplebin2.c","12345")
    c.do()
    print c.report()
           
            
    
